<% layout("/inc/layout_page.html"){ %>

<form action="${BASE}/admin/cms/CmsSlide/save" id="form_save" method="post">
<input type="hidden" id="id" name="id" value="${obj.id}">
<input type="hidden" id="sid" name="sid" value="${obj.sid}">
<div class="box">
  <div class="box-header">
    <h4 class="box-title"><i class="fa fa-bars"></i> 修改幻灯片</h4>
    <div class="box-tools">
      <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-save"></i> 保存</button>
      <a href="javascript:;" onclick="layer_close()" class="btn btn-info btn-sm"><i class="fa fa-chevron-left"></i> 返回</a>
    </div>
  </div>
  <div class="box-body">
    <table class="table tform table-bordered">
      <tr>
        <th><label for="cid">所属分类：</label></th>
        <td>
          <div class="col-xs-8">
			<select name="cid" class="form-control">
				<option value="0">默认分类</option>
				<% for(cat in catList){ %>
				<option value="${cat.id}" ${cat.id==obj.cid?"selected"} >${cat.name}</option>
				<% } %>
			</select>
		  </div>
          <div class="col-xs-4">&nbsp;</div>
        </td>
      </tr>
      <tr>
        <th><label for="name"><i class="required">*</i>幻灯片名称：</label></th>
        <td>
          <div class="col-xs-8"><input id="name" name="name" value="${obj.name}" type="text" class="form-control"></div>
          <div class="col-xs-4">&nbsp;</div>
        </td>
      </tr>
      <tr>
        <th><label for="url">链接地址：</label></th>
        <td>
          <div class="col-xs-8"><input id="url" name="url" value="${obj.url}" type="text" class="form-control"></div>
          <div class="col-xs-4">&nbsp;</div>
        </td>
      </tr>
      <tr>
        <th><label for="des">描述：</label></th>
        <td>
          <div class="col-xs-8"><input id="des" name="des" value="${obj.des}" type="text" class="form-control"></div>
          <div class="col-xs-4">&nbsp;</div>
        </td>
      </tr>
      <tr>
        <th><label for="remarks">文本介绍：</label></th>
        <td>
          <div class="col-xs-8">
            <textarea id="remarks" name="remarks" cols="" rows="" class="form-control"  placeholder="文本介绍...255个字符以内" dragonfly="true" onKeyUp="textarealength(this,255)">${obj.remarks}</textarea>
            <p class="textarea-numberbar"><em class="textarea-length">0</em>/255</p>
          </div>
          <div class="col-xs-4">&nbsp;</div>
        </td>
      </tr>
      <tr>
        <th><label for="content">富文本介绍：</label></th>
        <td>
          <div class="col-xs-8">
            <script id="content" name="content" type="text/plain">${obj.content}</script>
            <script type="text/javascript" src="${STATIC}/lib/ueditor/ueditor.config.js"></script>
            <script type="text/javascript" src="${STATIC}/lib/ueditor/ueditor.all.min.js"></script>
            <script type="text/javascript">UE.getEditor('content');</script>
          </div>
          <div class="col-xs-4">&nbsp;</div>
        </td>
      </tr>
      <tr>
        <th><label for="pic">图片：</label></th>
        <td>
          <div class="col-xs-3">
            <input id="pic" name="pic" type="hidden">
            <% if(isEmpty(obj.pic)){ %>
            <img id="fileImage" src="" class="img-thrum">
            <% } else { %>
            <img id="fileImage" src="${IMAGEPATH}/${obj.pic!}" class="img-thrum">
            <% } %>
            <span id="fileInfo"></span>
          </div>
          <div class="col-xs-9"><span id="picker">选择图片</span></div>
        </td>
      </tr>
    </table>
  </div>
  <div class="box-footer">
    <div class="box-tools pull-right">
      <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-save"></i> 保存</button>
      <a href="javascript:;" onclick="layer_close()" class="btn btn-info btn-sm"><i class="fa fa-chevron-left"></i> 返回</a>
    </div>
  </div>
</div>
</form>

<script type="text/javascript">
$(function(){
	
	uploadImage("picker","fileImage","fileInfo","pic");
	
	$("#form_save").validate({
		errorPlacement: function(error, element) {
			error.appendTo(element.parent().next());
		},
		submitHandler : function(form) {
			layer.load(1, {shade: [0.3,'#fff']});
			$(form).ajaxSubmit({
				dataType:"json",
				success:function( jsondata ){
					layer.closeAll('loading');
					if( jsondata.success){
						parent.toastr.success('保存成功！');
						parent.reload_table();
						layer_close();
					}else{
						parent.toastr.error(jsondata.msg);
					}
				}
			});
		},
		rules : {
			name : {
				required : true
			}
		}, 
		messages : { 
			name : { 
				required : "名称不能为空"
			}
		}
	});
});
</script>
<% } %>